<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of database
 *
 * @author ewerson
 */
class Database {

    private static $hostname = 'localhost';
    private static $username = 'root';
    private static $password = '123456';
    private static $database = 'pat';
    public static $conn;
    
    //teste
    // connection method
    public static function connect() {
        if (self::$conn == null) {
           

                self::$conn = mysql_connect(self::$hostname, self::$username, self::$password) or 
                        die(mysql_error() . "</br>  ");
                $db = mysql_select_db(self::$database, self::$conn) or 
                        die(mysql_error() . "</br> ");
                //
                               
                return self::$conn;
          
        }
        //echo 'Conexão reaproveitada';
        return self::$conn;
    }

    // destructor method
    public function __destruct() {
        
        mysql_close(self::$conn);
        echo 'Conexão fechada';
    }

}

?>
